package xin.marcher.module.lifecycle.api.impl;

import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import xin.marcher.module.common.core.JsonResult;
import xin.marcher.module.common.utils.ParamCheckUtil;
import xin.marcher.module.lifecycle.api.OperationalStaffApi;
import xin.marcher.module.lifecycle.domain.dto.OperationalStaffDTO;
import xin.marcher.module.lifecycle.domain.request.OperationalStaffRequest;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 *
 */
@Slf4j
@DubboService(version = "1.0.0", interfaceClass = OperationalStaffApi.class, retries = 0)
public class OperationalStaffApiImpl implements OperationalStaffApi {

    /**
     * 运营员信息：模拟数据
     */
    public static Map<Long, OperationalStaffDTO> operatorInfoMap = new HashMap<Long, OperationalStaffDTO>() {{
        put(1L, new OperationalStaffDTO(1L, "1", "张学友"));
        put(2L, new OperationalStaffDTO(2L, "2", "刘德华"));
        put(3L, new OperationalStaffDTO(3L, "3", "郭富城"));
    }};

    /**
     * 查询运营员工信息，在后续版本中提供运营权限系统接口进行查询，暂时使用，模拟数据获取运营员数据
     *
     * @param request
     * @return
     */
    @Override
    public JsonResult<OperationalStaffDTO> getOperationalStaff(OperationalStaffRequest request) {
        ParamCheckUtil.checkObjectNonNull(request);
        if (Objects.isNull(request.getId())) {
            return JsonResult.buildError("ID不能为空");
        }

        return JsonResult.buildSuccess(operatorInfoMap.get(request.getId()));
    }
}
